<?php

namespace app\admin\validate;

use think\Validate;

class AdminValidate extends Validate
{
    protected $message = [
        'id.require' => 'ID必须填写',
        'id.integer' => 'ID必须为整数',
        'user_name.require' => '管理员名称必须填写',
        'user_name.max' => '管理员名称最多不能超过20个字符',
        'mobile.require' => '手机号必须填写',
        'mobile.mobile' => '手机号格式错误',
        'email.email' => '邮箱格式错误',
        'email.max' => '邮箱最多不能超过50个字符',
        'password.require' => '密码必须填写',
        'password.min' => '密码最少不能少于6个字符',
        'password.max' => '密码最多不能超过255个字符',
        'avatar.url' => '头像必须为有效的URL地址',
        'status.in' => '状态值错误',
        'page.integer' => '页码必须为整数',
        'page.egt' => '页码必须大于等于1',
        'limit.integer' => '每页数量必须为整数',
        'limit.between' => '每页数量只能在1到100之间',
    ];
    protected $group = [
        'index' => [
            'page' => 'integer|egt:1',
            'limit' => 'integer|between:1,100',
            'user_name' => 'max:20',
            'mobile' => 'mobile',
            'email' => 'max:50|email',
            'status' => 'integer|in:0,1',
        ],
        'info' => [
            'id' => 'require|integer',
        ],
        'create' => [
            'user_name' => 'require|max:20',
            'mobile' => 'require|mobile',
            'email' => 'max:50|email',
            'password' => 'require|min:6|max:255',
            'avatar' => 'url',
            'status' => 'in:0,1',
        ],
        'update' => [
            'id' => 'require|integer',
            'user_name' => 'max:20',
            'mobile' => 'mobile',
            'email' => 'max:50|email',
            'password' => 'min:6|max:255',
            'avatar' => 'url',
            'status' => 'in:0,1',
        ],
        'delete' => [
            'id' => 'require|integer',
        ],
        'login' => [
            'user_name' => 'require|max:20',
            'password' => 'require|min:6|max:255',
        ],
        'grantRoles' => [
            'id' => 'require|integer',
        ],
    ];
}